﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufToolDefinition.h"
#include "GnufButtonControl.h"

namespace gnuf {

    class GNUF_BASE_EXPORT ButtonToolDefinition
        : public ToolDefinition
        , public IButtonControlHandler
    {
        CANNOT_COPY_OR_ASSIGN(ButtonToolDefinition)
        DEFINE_CAST_DERIVED2(gnuf::ButtonToolDefinition, gnuf::ToolDefinition, gnuf::IButtonControlHandler)
    public:
        static EItemType Type() { return ButtonControl::Type; }
        ButtonToolDefinition(
            const wchar_t *,
            bool, gcmp::OwnerPtr<Info> &,
            gcmp::OwnerPtr<Info> info2 = nullptr,
            bool wantToHandleToggling = false);
        ~ButtonToolDefinition();
        inline bool interactive() const { return m_interactive; }
        ButtonControl * buttonControl() { return m_buttonControl.get(); }
        const ButtonControl * buttonControl() const { return m_buttonControl.get(); }

        void setIsRecordCmd(bool val) { m_bRecordCmd = val; }
        bool isRecordCmd() const { return m_bRecordCmd; }

    protected:
        virtual bool onSupportToSelect() const { return m_interactive; }

        // Inherits from BottonToolDefinition...
        virtual void onRefreshData(const ToolDefinitionData &) override;

    private:
        bool m_interactive;
        bool m_bRecordCmd;
        gcmp::OwnerPtr<ButtonControl> m_buttonControl;
    };
}
